package com.asiainfo.kbisheet.control
{
	import flash.events.Event;
	
	import mx.controls.Alert;
	import mx.core.FlexGlobals;
	import mx.rpc.events.ResultEvent;
	
	public class KbsControlYunnan extends KbsControlBase implements IKbsControl
	{
		public function KbsControlYunnan()
		{
			super();
			_service.decrypt.addEventListener(ResultEvent.RESULT, decryptUserIdResult);
		}
		
		override public function getUserInfo():void{
			var user_id:String = FlexGlobals.topLevelApplication.parameters["user_id"]
			if(user_id){
				updateMessage("得到user_id：" + user_id);
				decrypt(null, user_id);				
			}
			else{
				Alert.show("无法获取当前用户身份。","错误");
				return;
			}
		}
		
		private function decryptUserIdResult(event:ResultEvent):void{
			kbsModel.userId = _service.decrypt.lastResult;
			updateMessage("得到解码后的user_id：" + kbsModel.userId);
			
			var newEvent:Event = new Event("getUserInfoComplete");
			dispatchEvent(newEvent);
		}
	}
}